package lab.page.action;

import java.util.LinkedList;
import java.util.List;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;

import lab.gene.service.impl.GeneServiceImpl;

public class ImageDeletePageAction extends ActionSupport implements ServletResponseAware, ServletRequestAware {
	
	private static final long serialVersionUID = 1L;
	private String userName;
	private List<String> geneList = null;
	private LinkedList<String> formList = new LinkedList<String>();
	private String result = null;
	
	protected HttpServletResponse servletResponse;  
	@Override   
	public void setServletResponse(HttpServletResponse servletResponse) {   
		this.servletResponse = servletResponse;   
	}   
	
	protected HttpServletRequest servletRequest;   
	@Override   
	public void setServletRequest(HttpServletRequest servletRequest) {   
		this.servletRequest = servletRequest;   
	}
	
	public String execute() {
		Cookie[] cookies = servletRequest.getCookies();
		String cookieName = "LabUser";
		if (cookies != null) {
			for (int i = 0; i < cookies.length; i++) {
				if (cookies[i].getName().equals(cookieName)) {
					setUserName(cookies[i].getValue());
					break;
				}
			}
		}
		GeneServiceImpl service = new GeneServiceImpl();
		setGeneList(service.getAllGeneNames());
		formList.add("001/002 PCR (A)");
		formList.add("001/026 PCR (C)");
		formList.add("002/027 PCR (C)");
		formList.add("001/028 PCR (D)");
		formList.add("002/029 PCR (D)");
		formList.add("Colony PCR confirm A (700-For/700-Rev)");
		formList.add("Colony PCR confirm B (700-For/700-Rev)");
		formList.add("Colony PCR confirm C (700-For/700-Rev)");
		formList.add("Colony PCR confirm D (700-For/700-Rev)");
		formList.add("B Genomic Prep form intermediates");
		formList.add("B Genomic Prep from finals");
		formList.add("'W' PCR from finals (use TS559 g-DNA)");
		formList.add("C Genomic Prep form intermediates");
		formList.add("C Genomic Prep from finals");
		formList.add("C Amplicon PCR");
		formList.add("D Genomic Prep form intermediates");
		formList.add("D Genomic Prep from finals");
		formList.add("D Amplicon PCR");
		System.out.println("result type="+result);
		return "success";
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public List<String> getGeneList() {
		return geneList;
	}

	public void setGeneList(List<String> geneList) {
		this.geneList = geneList;
	}

	public LinkedList<String> getFormList() {
		return formList;
	}

	public void setFormList(LinkedList<String> formList) {
		this.formList = formList;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

}
